package cn.zyq.ykb.controller.h5.product;

import cn.zyq.ykb.beans.product.Product;
import org.springframework.security.access.prepost.PreAuthorize;
import cn.zyq.ykb.system.ry.util.poi.ExcelUtil;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.beans.product.ProductOrder;
import cn.zyq.ykb.service.product.ProductOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.common.PageParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 商品订单Controller
 *
 * @author SystemAuth
 * @date 2023-11-02
 */

@RestController(value = "H5ProductOrderController")
@RequestMapping("/api/productOrder")
@Api(tags = "商品订单接口")
public class ProductOrderController extends BaseController {

    @Autowired
    private ProductOrderService productOrderService;

    /**
     * 查询商品订单列表
     */
    @ApiOperation(value = "列表", response = ProductOrder.class)
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.productOrderService.selectProductOrderList(pageParam,this.getLoginUser());
    }
    /**
     * 获取商品订单详细信息
     */
    @ApiOperation(value = "详情", response = ProductOrder.class)
    @GetMapping(value = "/{productOrderID}")
    public Object getInfo(@PathVariable("productOrderID") Integer productOrderID) {
        return this.productOrderService.selectProductOrderByProductOrderID(productOrderID);
    }

    /**
     * 获取商品订单详细信息
     */
    @ApiOperation(value = "商品下单", response = ProductOrder.class)
    @PostMapping(value = "/placeOrder")
    public Object placeOrder(@RequestBody Product product) {
        return this.productOrderService.placeOrder(product,this.request,this.getLoginUser());
    }

}
